<!DOCTYPE html>
<html ng-app="demoApp">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width,initial-scale=1">
        <meta name="description" content="A fully featured admin theme which can be used to build CRM, CMS, etc.">
        <meta name="author" content="Coderthemes">

        <link rel="shortcut icon" href="assets/images/favicon_1.ico">

        <title>圣斯尔监控系统</title>

        <link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
        <link href="assets/css/core.css" rel="stylesheet" type="text/css">
        <link href="assets/css/icons.css" rel="stylesheet" type="text/css">
        <link href="assets/css/components.css" rel="stylesheet" type="text/css">
        <link href="assets/css/pages.css" rel="stylesheet" type="text/css">
        <link href="assets/css/menu.css" rel="stylesheet" type="text/css">
        <link href="assets/css/responsive.css" rel="stylesheet" type="text/css">
        <link href="assets/plugins/sweetalert/sweetalert.css" rel="stylesheet" type="text/css">

        <script src="assets/js/modernizr.min.js"></script>


        <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
        <![endif]-->

        
    </head>
    <body ng-controller="loginCtrl">


        <div class="wrapper-page">
            <div class="panel panel-color panel-primary panel-pages">
                <div class="panel-heading bg-img"> 
                    <div class="bg-overlay"></div>
                    <h3 class="text-center m-t-10 text-white"> 圣斯尔物联网监测平台登录 </h3>
                </div> 


                <div class="panel-body">
                <form class="form-horizontal m-t-20" ng-submit="login()" >
                    
                    <div class="form-group">
                        <div class="col-xs-12">
                            <input class="form-control input-lg" type="text" required="" placeholder="请输入账号" ng-model="userNo">
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-xs-12">
                            <input class="form-control input-lg" type="password" required="" placeholder="请输入密码" ng-model="password">
                        </div>
                    </div>

                <!--    <div class="form-group">
                        <div class="col-xs-12">
                            <div class="checkbox checkbox-primary">
                                <input id="checkbox-signup" type="checkbox">
                                <label for="checkbox-signup">
                                    	记住我
                                </label>
                            </div>
                            
                        </div>
                    </div>-->
                    
                    <div class="form-group text-center m-t-40">
                        <div class="col-xs-12">
                            <button class="btn btn-primary btn-lg w-lg waves-effect waves-light" type="submit" btn-loading="loading">登录</button>
                        </div>
                    </div>

                    <!-- <div class="form-group m-t-30">
                        <div class="col-sm-7">
                            <a href="recoverpw.html"><i class="fa fa-lock m-r-5"></i> Forgot your password?</a>
                        </div>
                        <div class="col-sm-5 text-right">
                            <a href="register.html">Create an account</a>
                        </div>
                    </div> -->
                </form> 
                </div>                                 
                
            </div>
        </div>

        
    	<script>
            var resizefunc = [];
        </script>

        <!-- Main  -->
        <script src="assets/js/jquery.min.js"></script>
        <script src="assets/js/bootstrap.min.js"></script>
        <script src="assets/js/detect.js"></script>
        <script src="assets/js/fastclick.js"></script>
        <script src="assets/js/jquery.slimscroll.js"></script>
        <script src="assets/js/jquery.blockUI.js"></script>
        <script src="assets/js/waves.js"></script>
        <script src="assets/js/wow.min.js"></script>
        <script src="assets/js/jquery.nicescroll.js"></script>
        <script src="assets/js/jquery.scrollTo.min.js"></script>
        <!-- Sweet-Alert  -->
        <script src="assets/plugins/sweetalert/sweetalert.min.js"></script>

        <script src="assets/js/jquery.app.js"></script>
        

        <script type="text/javascript" src="static/js/angular-1.5.8.min.js"></script>
        <!-- md5 -->
        <script src="assets/js/md5.js"></script>

        <script type="text/javascript">


            var demoApp = angular.module("demoApp", []);
            demoApp.controller("loginCtrl", function($scope, $http) {
                //设置按钮是否显示加载中不可用
                $scope.loading=false;
                $http.post("service/checkLogin").success(function(data) {
                    //已登陆则跳回首页
                   if(data.resultObj){
                       window.location.href="/";
                   }
                });

                //
                $scope.login=function(){
                    $scope.loading=true;
                    //加密密码
                    $scope.encordPassword = hex_md5($scope.password);
                    $http.post("service/login",{"userNo":$scope.userNo,"password":$scope.encordPassword}).success(function(data) {
                        //todo 密码或账号错误
                        $scope.loading=false;
                        if(data.success){
                            window.location.href="/";
                        }else{
                            $scope.userNo="";
                            $scope.password="";
                            $scope.encordPassword="";
                            swal("用户名或密码错误！");
                        }

                    });
                }

            });
        </script>
    <script type="text/javascript" src="app/directive/btnLoadDirectives.js"></script>
	</body>
</html>